// pages/user/index.js
const DB=wx.cloud.database().collection("User")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userinfo:{},
    collectNum:0,
    admin:false
  },

  onShow(){
    const userinfo=wx.getStorageSync('userInfo');
    const collect=wx.getStorageSync('collect')||[];
    
    this.setData({
      userinfo:userinfo,
      collectNum:collect.length
    })
    
    let that=this
    const openId=wx.getStorageSync('openid');
    DB.where({userOpenid:openId}).get({
      success(res){
        //登录成功
        if(res.data.length>=1){
          that.setData({
            admin:true
          })
        }
      }
    })
  },

  //查看订单
  bindOrder(){
    wx.showToast({
      title: '无订单信息',
      icon:'none',
      mask:'true'
    })
  },

  //查看收藏店铺
  bindDp(){
    wx.showToast({
      title: '功能未开放',
      icon:'none',
      mask:'true'
    })
  },
  handPhone(){
    wx.makePhoneCall({
      phoneNumber: '13133334468',
    })
  }

})